package com.torfox.modules.livelog;

import javax.servlet.http.HttpServletRequest;

import org.eclipse.jetty.websocket.WebSocket;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class LiveLogConnectionFactory implements ApplicationContextAware
{
	private ApplicationContext applicationContext;

	@Override
	public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException
	{
		this.applicationContext = applicationContext;
	}

	public WebSocket createConnection(final HttpServletRequest request, final String protocol)
    {
		final LiveLogConnection connection = new LiveLogConnection(request, applicationContext);
	    return connection;
    }

}
